$('#btnSend_'+type).bind('click', function(){
	submit_form(type+'_form', function(resp){
                if(type=="user_list"){
                    var member = new Array();
                    member = $("#usrm_role").val();
                    var data = new Array();
                    data={"id":$("#role_id").val(),"member":member,"user":$("#USERNAME").val()};
                    $.post(host+"setup/saveData/user_member",data,function(resp){
                        //alert(resp);
                    })
                }
                if(resp == 1){
			kembali(type);
                        $.messager.alert('Sukses','Data Tersimpan','Sukses');
		}else{
			//$.messager.alert('Gagal','Data Gagal Tersimpan','Gagal');
			$.messager.alert('Gagal',resp,'Gagal');
		}
		
	})
});

function kembali(typenya){
	_post = [{name:'type', value: typenya}];		
	$('#setup_'+typenya).html('');
	$('#setup_'+typenya).addClass("loading");
	$.post(host+'setup/gettab/', _post, function(resp) {
		$('#setup_'+typenya).removeClass('loading')
		$('#setup_'+typenya).html(resp);							
	});	
}

$("body").off("#usrm_toright");
$("body").on("click","#usrm_toright",function(e){
    e.preventDefault();
    if($('#usrm_role1 :selected').length > 0){
        $('#usrm_role').append($('#usrm_role1 :selected')); 
    }
});
		
$("body").off("#usrm_toleft");
$("body").on("click","#usrm_toleft",function(e){
    e.preventDefault();
    if($('#usrm_role :selected').length > 0){
        $('#usrm_role1').append($('#usrm_role :selected'));
    }
});


